In [2]:
%matplotlib inline
import numpy as np
from scipy import misc
import matplotlib.pyplot as plt
import imageio
In [3]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
In [4]:
type(photo_data)
Out[4]:
imageio.core.util.Array
In [5]:
plt.figure(figsize=(15,15))
Out[5]:
<Figure size 1080x1080 with 0 Axes>
<Figure size 1080x1080 with 0 Axes>
In [6]:
plt.imshow(photo_data)
Out[6]:
<matplotlib.image.AxesImage at 0x107bffd0>
In [7]:
photo_data.shape
Out[7]:
(3725, 4797, 3)
In [8]:
photo_data.size
Out[8]:
53606475
In [9]:
photo_data[150,250]
Out[9]:
Array([ 15,  42, 233], dtype=uint8)
In [10]:
photo_data[200:800, :, 1] = 255
In [11]:
plt.figure(figsize=(10,10))
Out[11]:
<Figure size 720x720 with 0 Axes>
<Figure size 720x720 with 0 Axes>
In [12]:
plt.imshow(photo_data)
Out[12]:
<matplotlib.image.AxesImage at 0x111da950>
In [ ]:
 
In [13]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
In [14]:
photo_data[200:800, :] = 255
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
Out[14]:
<matplotlib.image.AxesImage at 0x11224090>
In [15]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
print("Shape of photo-data:", photo_data.shape)
low_value_filter = photo_data < 200
print("Shahpe of low_value_filter:",low_value_filter.shape)
Shape of photo-data: (3725, 4797, 3)
Shahpe of low_value_filter: (3725, 4797, 3)
In [16]:
import random
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
photo_data[low_value_filter] = 0
plt.figure(figsize=(10,10))
plt.imshow(photo_data)
Out[16]:
<matplotlib.image.AxesImage at 0x1127b9f0>
In [18]:
total_rows, total_cols, total_layers = photo_data.shape
In [20]:
X, Y = np.ogrid[:total_rows, :total_cols]
print("X= ",X.shape, "and Y = ", Y.shape)
X=  (3725, 1) and Y =  (1, 4797)
In [21]:
center_row, center_col = total_rows/2, total_cols/2
In [24]:
dist_center = (X - center_row)**2 + (Y - center_col)**2
#print(dist_center)
radius = (total_rows / 2)**2
#print(radius)
circ_mark = (dist_center > radius)
#print(circ_mark)
#print(circ_mark[1500:1700,2000:2200])
In [26]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
photo_data[circ_mark] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[26]:
<matplotlib.image.AxesImage at 0x11257cb0>
In [27]:
X, Y = np.ogrid[:total_rows, :total_cols]
half_upper = X < center_row
half_upper_mask = np.logical_and(half_upper, circ_mark)
In [28]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
photo_data[half_upper_mask] = 255
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[28]:
<matplotlib.image.AxesImage at 0x11282810>
In [30]:
photo_data = imageio.imread("E:\Python\Wifire\sd-3layers.jpg")
red_mask = photo_data[:, : ,0] < 150
photo_data[red_mask] = 0
plt.figure(figsize=(15,15))
plt.imshow(photo_data)
Out[30]:
<matplotlib.image.AxesImage at 0xb89310>
In [ ]: